<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="__RES__/css/login.css" rel="stylesheet" type="text/css" />
<script src="__RES_ROOT__/js/jquery.js"></script>
</head>

<body class="special_page">
<div class="top">
  <div class="gradient"></div>
  <div class="white"></div>
  <div class="shadow"></div>
</div> 
 <div class="content"> 
   <h1>系统管理平台</h1> 
   <div class="background"></div>
   <div class="wrapper"> 
      <div class="box"> 
          <div class="header"><img src="__RES__/img/lock.png" width="16" height="16"><h3>管理员登陆</h3></div>
        <form action="?a=doLogin" method="post" id="loginForm">
         <div class="content_with">
         <div class="section"> 
         <div class="item">
           <label for="user_name" class="user">用户:<input name="login_name" id="login_name" type="text" size="30" maxlength="32"></label></div>
         <div class="item">
           <label for="password" class="pwd">密码:<input name="login_pwd" id="login_pwd" size="25" type="password" size="30" maxlength="32"></label></div>
         </div>
         </div> 
         <div class="actions"> 
          <input type="button" id="btnLogin" value="立即登录" class="button">
          </div> </form>
       </div> 
      <div class="shadow"></div> 
   </div>
</div> 
<script>
$(function(){
    $(window).on('LOGIN', function(e, d){
        if(!d.s) {
            alert(d.m);

            return false;
        }

        window.location = '?';
    })

    $('#btnLogin').click(function(){
        var $name = $('#login_name'),
            $passwd = $('#login_pwd'),
            name = $name.val(),
            passwd = $passwd.val(),
            url = $('#loginForm').attr('action');

        if(name.length < 1) {
            alert('请输入登陆名称');
            $name.focus();

            return false;
        }

        if(passwd.length < 1) {
            alert('请输入密码');
            $passwd.focus();

            return false;
        }

        $.post(url, {name : name, passwd : passwd}, function(j){
            $(window).trigger('LOGIN', j);
        }, 'json');
    });

    $(window).on('keydown', function(e){
        if(e.keyCode == '13') {
            $('#btnLogin').trigger('click');
        }
    })

    $('[name=login_name]').focus();
});
</script>
</body>
</html>
